function typeOf(obj: any) {
	const toString = Object.prototype.toString;
	const map = {
		'[object Boolean]': 'boolean',
		'[object Number]': 'number',
		'[object String]': 'string',
		'[object Function]': 'function',
		'[object Array]': 'array',
		'[object Date]': 'date',
		'[object RegExp]': 'regExp',
		'[object Undefined]': 'undefined',
		'[object Null]': 'null',
		'[object Object]': 'object',
	};
	return map[toString.call(obj)];
}

/**
 * 深拷贝
 * */
export function deepCopy(data: any) {
	const t = typeOf(data);
	let o: any;

	if (t === 'array') {
		o = [];
	} else if (t === 'object') {
		o = {};
	} else {
		return data;
	}

	if (t === 'array') {
		for (let i = 0; i < data.length; i++) {
			o.push(deepCopy(data[i]));
		}
	} else if (t === 'object') {
		for (const i in data) {
			o[i] = deepCopy(data[i]);
		}
	}
	return o;
}

/**
 * 处理数组假值
 * @param arr 待处理数据
 * @returns {Array}
 * */
export function getRealValue(arr: Array<any>): Array<any> {
	return arr.filter(value => {
		return value;
	});
}
